/*
 * @(#) MotanConfiguration.java 2018-09-20
 *
 * Copyright 2018 NetEase.com, Inc. All rights reserved.
 */

package com.xinyi.order.provdier.motan;

import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import com.xinyi.order.provdier.config.MotanConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class MotanConfiguration {

    @Autowired
    private MotanConfig motanConfig;

    @Bean
    public AnnotationBean motanAnnotationBean() {
        AnnotationBean motanAnnotationBean = new AnnotationBean();
        motanAnnotationBean.setPackage("com.xinyi.order.provdier.impl");
        return motanAnnotationBean;
    }

    @Bean(name = "orderMotan")
    public ProtocolConfigBean protocolConfig1() {
        ProtocolConfigBean config = new ProtocolConfigBean();
        config.setDefault(true);
        config.setName("motan");
        config.setMaxContentLength(1048576);
        return config;
    }

    @Bean(name = "registryConfig")
    public RegistryConfigBean registryConfig() {
        RegistryConfigBean config = new RegistryConfigBean();
        config.setRegProtocol("zookeeper");
        config.setBeanName("zkRegistryConfig");
        config.setAddress("118.25.142.204:2181");
        return config;
    }

    @Bean
    public BasicServiceConfigBean baseServiceConfig() {
        BasicServiceConfigBean config = new BasicServiceConfigBean();
        config.setExport("orderMotan:8111");
        config.setGroup("OrderGroup");
        config.setAccessLog(false);
        config.setShareChannel(true);
        config.setModule("motan-order-rpc");
        config.setApplication("OrderProvider");
        config.setRegistry("registryConfig");
        return config;
    }


}
